<template>
    <div class="content">
        <div class="row">
            <div class="col-md-1 col-md-offset-6" style="padding:0;font-weight:700">
                当前环节：
            </div>
            <div class="col-md-5">
                审核
            </div>
        </div>
        <div class="row">
            <div class="col-md-1" style="padding:0;font-weight:700">
                审核结果：
            </div>
            <div class="col-md-2">
                <input type="radio" name="optionsRadios" id="optionsRadios1" value="1" checked="checked" v-model="picked">
                <span>通过</span>
                <input type="radio" name="optionsRadios" id="optionsRadios1" value="0" v-model="picked">
                <span>不通过</span>
            </div>
            <div class="col-md-1 col-md-offset-3" style="padding:0;font-weight:700">
                时间：
            </div>
            <div class="col-md-5">
                {{getDate()}}
            </div>
        </div>
        <div class="row" v-if="picked==0">
            <div class="col-md-1" style="padding:0;font-weight:700">
                不通过原因：
            </div>
            <div class="col-md-9">
                <textarea class="form-control" rows="3" placeholder="请输入不通过原因" v-model="reviewData.reviewReason" maxlength="80"></textarea>
            </div>
        </div>
        <div class="row" style="margin-top:100px">
            <div class="col-md-1 col-md-offset-4">
                <button type="button" class="btn btn-block btn-primary" @click="getEventReview">提交</button>
            </div>
            
        </div>
    </div>
</template>

<script>
import utils from "@/utils";
import { getUserInfo } from "@/utils/auth";

export default {
    props: ["formList"],

    data() {
        return {
            reviewData: {
                orderId: "",
                reviewStatus: "",
                reviewPerson: "",
                reviewReason: "",
                personId:"",
                peopleId:'',
            },
            picked: "1"
        };
    },
    mounted() {
        // this.getEventWorkinfo();
    },
    methods: {
        getDate() {
            return utils.getDate();
        },
        getEventReview() {
            this.reviewData.orderId = this.formList.orderId;
            this.reviewData.reviewPerson = getUserInfo().username;
            this.reviewData.reviewStatus = this.picked;
            this.$api.ticket.list.eventReview(this.reviewData).then(res => {
                if (res.success) {
                    console.log(res);
                    if (this.picked == 1) {
                        this.formList.orderStatus = res.data;
                        this.$$message({
                            message: "恭喜您，审核成功！",
                            type: "success"
                        });
                    } else {
                        this.formList.orderStatus = res.data;
                        this.$$message({
                            message: "对不起，审核不通过！",
                            type: "error"
                        });
                    }
                    this.$parent.$refs.detailmsgComp.getEventWorkinfo();
                    this.$parent.$refs.detailmsgComp.$parent.getSelEventId();
                    this.$emit("isActive");
                }
                else{
                    this.$$message({
                            message: res.msg,
                            type: "error"
                        });
                }
            });
        },
        getEventWorkinfo() {
            this.$api.ticket.list
                .eventWorkinfo({
                    orderId: this.formList.orderId
                })
                .then(res => {
                    if (res.success) {
                        this.reviewData.personId =
                            res.data.workList[0].personId;
                            this.reviewData.peopleId =
                            res.data.materialList[0].personId;
                    }
                });
        },
    }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.content {
    .row {
        margin: 27px 0;
    }
    .col-md-1 {
        text-align: right;
        height: 32px;
        line-height: 32px;
    }
    .col-md-5 {
        height: 32px;
        line-height: 32px;
        color: #b2afb3;
    }
    select {
        width: 200px;
        height: 32px;
        line-height: 32px;
        padding-top: 4px;
        color: #b2afb3;
        border-radius: 5px;
    }
    input {
        height: 32px;
        line-height: 32px;
        float: left;
        margin: 0 5px 0 0;
    }
    span {
        display: inline-block;
        height: 32px;
        line-height: 32px;
        width: 50px;
        float: left;
    }
}
</style>
